﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using Magic;
using Microsoft.Win32;

namespace BioShock_Cheata
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public IntPtr baseadd;
        public uint silver;
       public uint saltvia;

       public BlackMagic bio = new BlackMagic();
        private void Form1_Load(object sender, EventArgs e)
        {
            bio.OpenProcessAndThread(SProcess.GetProcessFromWindowTitle("BioShock Infinite"));
            bio.SetDebugPrivileges = true;
            baseadd = bio.MainModule.BaseAddress;
            uint siver = bio.ReadUInt((uint)baseadd + 0x012DE7C0);
            siver += 0x208;
            siver = bio.ReadUInt(siver);
            siver += 0x8;
            siver = bio.ReadUInt(siver);
            siver += 0x4;
            siver = bio.ReadUInt(siver);
            siver += 0xc;
            siver = bio.ReadUInt(siver);
            siver += 0x508;
            silver = siver;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (label2.Text == "off")
            {
                label2.Text = "on";
                button1.Text = "Stop";//Lets start
                timer1.Enabled = true;
                if (checkBox2.Checked)//salt
                {
                    uint salt = bio.ReadUInt((uint)baseadd + 0x012DE7E4);
                    salt += 0x194;
                    salt = bio.ReadUInt(salt);
                    salt += 0x4;
                    salt = bio.ReadUInt(salt);
                    salt += 0x74;
                    saltvia = salt;
                    bio.WriteUInt(saltvia, 100);
                }
                
            }
            else
            {
                label2.Text = "off";
                button1.Text = "Start";//Lets stop
                timer1.Enabled = false;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            if (checkBox2.Checked)//salt
            {
                bio.WriteUInt(saltvia, 100);
            }

            
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            label4.Text = bio.ReadUInt(bio.ReadUInt(bio.ReadUInt(bio.ReadUInt(bio.ReadUInt(bio.ReadUInt((uint)baseadd + 0x012DE7C0) + 0x208) + 0x8) + 0x4) + 0xc) + 0x508).ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            bio.WriteUInt(silver, Convert.ToUInt32(label4.Text) + 500);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            bio.WriteUInt(silver, Convert.ToUInt32(label4.Text) + 100);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            bio.WriteUInt(silver, Convert.ToUInt32(label4.Text) + 1000);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            bio.WriteUInt(silver, Convert.ToUInt32(label4.Text) + 5000);
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
